import router from '@system.router';

export default {
    data: {
        title: 'World',
        num:5,
        an1:"",
        an2:"",
        opacity: 0.5
    },
    onInit() {
        let  that=this;
        let aa=setInterval(function () {
            that.num--;
            if(that.num==0){
                //settimeout清楚函数,只执行一次
                this.opacity = 0
                this.num = 5
//                setTimeout(function(){
//                    router.replace({
//                        uri:"pages/action_video_2/action_video_2"
//                    })
//
//                },2000)

//                this.opacity=0
//                router.back();

                clearInterval(aa);

            }

        },1000)
    },
    onShow(){
        this.loadan1();
        this.loadan2();
    },
    loadan1(){

        //动画的规则
        let key=[{transform:{translate:'1000px -100px'}},
                 {transform:{translate:'390px 300px'}}
        ];
        //动画的选项
        let options={
            duration:5000,
            easing:"linear",
            fill:"forwards",
            iterations:1    //执次数
        }
        //通过id作用于topone
        this.an1=this.$element("topone").animate(key,options);
        //播放动画
        this.an1.play();
    },
    loadan2(){
        //动画的规则
        let key=[{transform:{translate:'-500px  200px'}},
                 {transform:{translate:'-100px -200px'}}
        ];
        //动画的选项
        let options={
            duration:5000,
            easing:"linear",
            fill:"forwards",
            iterations:1    //执次数
        }
        //通过id作用于topone
        this.an2=this.$element("bottomone").animate(key,options);
        //播放动画
        this.an2.play();
    }

}
